﻿<phone:PhoneApplicationPage 
    x:Class="SSTU.View.FacultyMenuPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
	xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
	xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
	xmlns:sstuBehavior="clr-namespace:SSTU.Controls.Behavior"
	xmlns:interactivity="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
	xmlns:interaction="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
	DataContext="{Binding Path=FacultyMenuViewModel, Source={StaticResource ViewModelLocator}}">

	<Grid x:Name="LayoutRoot" Background="Transparent">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
		</Grid.RowDefinitions>
		<toolkit:PerformanceProgressBar IsIndeterminate="{Binding Path=IsBusy}" />
		<TextBlock Grid.Row="1" Margin="24,24,24,0" TextWrapping="Wrap">
			<Run
				Text="{Binding Path=ShortName, Mode=OneWay}"
				FontSize="{StaticResource PhoneFontSizeLarge}">
			</Run>
			<LineBreak />
			<Run Text="{Binding Path=LongName, Mode=OneWay}" />
		</TextBlock>
		<TextBlock Text="&lt;пусто&gt;" Grid.Row="2" Margin="24,24,0,0" Style="{StaticResource PhoneTextSubtleStyle}">
			<interaction:Interaction.Triggers>
				<interactivity:DataTrigger Binding="{Binding Path=Groups.Count}" Value="0" Comparison="Equal">
					<interactivity:ChangePropertyAction PropertyName="Visibility">
						<interactivity:ChangePropertyAction.Value>
							<Visibility>Visible</Visibility>
						</interactivity:ChangePropertyAction.Value>
					</interactivity:ChangePropertyAction>
				</interactivity:DataTrigger>
				<interactivity:DataTrigger Binding="{Binding Path=Groups.Count}" Value="0" Comparison="NotEqual">
					<interactivity:ChangePropertyAction PropertyName="Visibility">
						<interactivity:ChangePropertyAction.Value>
							<Visibility>Collapsed</Visibility>
						</interactivity:ChangePropertyAction.Value>
					</interactivity:ChangePropertyAction>
				</interactivity:DataTrigger>
			</interaction:Interaction.Triggers>
		</TextBlock>
		<ScrollViewer Grid.Row="2" Margin="24,24,0,0">
			<ItemsControl ItemsSource="{Binding Path=Groups}" Margin="0,12,0,0">
				<ItemsControl.ItemTemplate>
					<DataTemplate>
						<Grid x:Name="ItemLayoutRoot" Margin="0,0,24,18" Background="Transparent" sstuBehavior:TiltEffect.IsTiltEnabled="True">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="*" />
								<ColumnDefinition Width="Auto" />
							</Grid.ColumnDefinitions>
							<TextBlock Text="{Binding Path=ShortName}" FontSize="{StaticResource PhoneFontSizeExtraLarge}" Grid.Column="0">
							</TextBlock>
							<Path Grid.Column="1" VerticalAlignment="Center" Visibility="{Binding Path=IsFavorite, Converter={StaticResource TrueToVisibleConverter}}" Fill="{StaticResource PhoneAccentBrush}" StrokeThickness="0" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeLineJoin="Round" Data="M 0,10 l 10,0 l 5,-10 l 5,10 l 10,0 l -7,10 l 2,10 l -10,-5 l -10,5 l 2,-10 Z" />
							<Rectangle Grid.ColumnSpan="2" Fill="Transparent">
								<toolkit:GestureService.GestureListener>
									<toolkit:GestureListener Tap="OnGroupItemTap"></toolkit:GestureListener>
								</toolkit:GestureService.GestureListener>
								<toolkit:ContextMenuService.ContextMenu>
									<toolkit:ContextMenu>
										<toolkit:MenuItem
											x:Name="FavoriteMenuItem"
											Header="{Binding Path=FavoriteCommandCaption}"
											Command="{Binding Path=FacultyMenuViewModel.FavoriteCommand, Source={StaticResource ViewModelLocator}}"
											CommandParameter="{Binding Path=.}">
										</toolkit:MenuItem>
									</toolkit:ContextMenu>
								</toolkit:ContextMenuService.ContextMenu>
							</Rectangle>
						</Grid>
					</DataTemplate>
				</ItemsControl.ItemTemplate>
			</ItemsControl>
		</ScrollViewer>
	</Grid>

</phone:PhoneApplicationPage>
